package cn.t.dynamic.switcher.demo;

import cn.t.dynamic.switcher.annotation.Dynamic;
import cn.t.dynamic.switcher.demo.domain.Demo;
import cn.t.dynamic.switcher.demo.mapper.DemoMapper;
import cn.t.dynamic.switcher.type.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DemoService {
    @Autowired
    private DemoMapper mapper;

    @Dynamic(type = DataSourceType.SLAVE)
    public void insert() {
        Demo d = new Demo();
        d.setName("aa");
        this.mapper.insert(d);
    }
}
